﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BitBitty.Portal.Identity
{
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("DefaultConnection")
        {
            Database.SetInitializer<ApplicationDbContext>(new NullDatabaseInitializer<ApplicationDbContext>());
        }

        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            //over write the default mapping
            modelBuilder.Entity<ApplicationUser>().ToTable("Users", "Membership");
            modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogins", "Membership");
            modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims", "Membership");
            modelBuilder.Entity<IdentityRole>().ToTable("Roles", "Membership");
            modelBuilder.Entity<IdentityUserRole>().ToTable("UserRoles", "Membership");
        }

        public static ApplicationDbContext Create()
        {
            return new ApplicationDbContext();
        }
    }
}
